<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>

<input id="r1_1" type="radio">

<input id="r2_1" name="r2" type="radio">
<input id="r2_2" name="r2" type="radio">
<input id="r2_3" name="r2" type="radio">

<input id="r3_1" name="r3" checked type="radio">

<input id="r4_1" name="r4" type="radio">
<input id="r4_2" name="r4" type="radio">

<script>
description('This tests :indeterminate pseudo class matches when there is no checked radio button in a radio button group.');

function test1() {
    r1_1 = document.getElementById('r1_1');
    debug('If a name isn\'t specified, it is in its own radio group.');
    shouldBeTrue('r1_1.matches(":indeterminate")');
    debug('Setting indeterminate property shouldn\'t affect radio buttons.');
    r1_1.indeterminate = true;
    shouldBeTrue('r1_1.matches(":indeterminate")');
    r1_1.checked = true;
    shouldBeFalse('r1_1.matches(":indeterminate")');
    r1_1.indeterminate = false;
    shouldBeFalse('r1_1.matches(":indeterminate")');
}

function test2() {
    debug('Changing checked should affect the matching of other buttons within the radio group.');
    r2_1 = document.getElementById('r2_1');
    r2_2 = document.getElementById('r2_2');
    r2_3 = document.getElementById('r2_3');
    shouldBeTrue('r2_1.matches(":indeterminate")');
    shouldBeTrue('r2_2.matches(":indeterminate")');
    shouldBeTrue('r2_3.matches(":indeterminate")');
    r2_1.checked = true;
    shouldBeFalse('r2_1.matches(":indeterminate")');
    shouldBeFalse('r2_2.matches(":indeterminate")');
    shouldBeFalse('r2_3.matches(":indeterminate")');
    r2_2.checked = true;
    shouldBeFalse('r2_1.matches(":indeterminate")');
    shouldBeFalse('r2_2.matches(":indeterminate")');
    shouldBeFalse('r2_3.matches(":indeterminate")');
    r2_2.checked = false;
    shouldBeTrue('r2_1.matches(":indeterminate")');
    shouldBeTrue('r2_2.matches(":indeterminate")');
    shouldBeTrue('r2_3.matches(":indeterminate")');
}

function test3() {
    debug('Adding/removing a button from a group should affect the matching.');
    r3_1 = document.getElementById('r3_1');
    r4_1 = document.getElementById('r4_1');
    r4_2 = document.getElementById('r4_2');
    shouldBeFalse('r3_1.matches(":indeterminate")');
    shouldBeTrue('r4_1.matches(":indeterminate")');
    shouldBeTrue('r4_2.matches(":indeterminate")');
    r3_1.name = 'r4';
    shouldBeFalse('r3_1.matches(":indeterminate")');
    shouldBeFalse('r4_1.matches(":indeterminate")');
    shouldBeFalse('r4_2.matches(":indeterminate")');
    r3_1.name = 'r3';
    shouldBeFalse('r3_1.matches(":indeterminate")');
    shouldBeTrue('r4_1.matches(":indeterminate")');
    shouldBeTrue('r4_2.matches(":indeterminate")');
}

test1();
test2();
test3();

</script>
</body>
</html>
